package com.wjjm.spoonselling.dao;

import com.wjjm.spoonselling.pojo.Commodity;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommodityDao {

    @Select("select * from commodity")
    List<Commodity> selectAll();

    @Select("select * from commodity where commodityId=#{commodityId}")
    Commodity selectById(int commodityId);

    //根据商品名称进行模糊查询
    @Select("select * from commodity where name like #{name}")
    List<Commodity> selectByName(String name);

    @Update("update commodity set name=#{name},price=#{price},inventory=#{inventory},volume=#{volume},image=#{image} where commodityId=#{commodityId}")
    int update(Commodity commodity);

    @Delete("delete from commodity where commodityId=#{commodityId}")
    int deleteById(int commodityId);

    @Insert("insert into commodity (commodityId,name,price,inventory,volume,image) values(#{commodityId},#{name},#{price},#{inventory},#{volume},#{image})")
    int insert(Commodity commodity);

}
